package cn.project.lemontree.service.impl;

import cn.project.lemontree.bean.Notice;
import cn.project.lemontree.bean.Notice_Per;
import cn.project.lemontree.bean.Parent;
import cn.project.lemontree.dao.NoticeDao;
import cn.project.lemontree.dao.Notice_PerDao;
import cn.project.lemontree.service.NoticeService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("noticeService")
public class NoticeServiceimpl extends ServiceImpl<NoticeDao, Notice> implements NoticeService {
    @Resource
    private NoticeDao noticeDao;
    @Resource
    private Notice_PerDao notice_perDao;

    @Override
    public boolean save(Notice notice, List<Integer> parent_ids,List<Integer> teacher_ids){
        for(Integer parent_id : parent_ids){
            notice_perDao.save(new Notice_Per(notice,parent_id,0));
        }
        for(Integer teacher_id : teacher_ids){
            notice_perDao.save(new Notice_Per(notice,teacher_id,1));
        }
        return noticeDao.save(notice) > 0;
    }
}
